<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link rel="stylesheet" href="/js/login/css/login.css">

    <script src="/js/login/js/jQuery1.7.js"></script>
    <script src="/js/login/js/jquery-1.8.2.min.js"></script>
    <script src="/js/login/js/Validform_v5.3.2_min.js"></script>
    <script src="/js/jquery-1.8.0.js"></script>
    <link rel="stylesheet" href="/layer/theme/default/layer.css">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layer/layer.js"></script>
    <link rel="stylesheet" href="/layer/mobile/need/layer.css">
    <script src="/layer/mobile/layer.js"></script>
    <link rel="stylesheet" href="/layer/theme/default/layer.css">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/layui/css/layui.mobile.css">
    <script src="/layui/layui.all.js"></script>

    <!--qq登录-->
    <script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js" data-appid="100229030" charset="utf-8">


    </script>
    <script type="text/javascript">
        QC.Login({
            btnId:"qqLoginBtn"	//插入按钮的节点id
        });
    </script>

    <script>
        var jsAssets = {
            'jq':'http://i0.sinaimg.cn/dy/js/jquery/jquery-1.7.2.min.js',
            'outloginLayer':'http://i.sso.sina.com.cn/js/outlogin_layer.js',
            'userPanel':'http://i.sso.sina.com.cn/js/user_panel_new_version_v2.js',
            'ssoLogin':'http://tech.sina.com.cn/js/717/20140827/index2014/top.js',
            'topNav':'http://n.sinaimg.cn/common/channelnav/js/nav.js'
        };
    </script>
    <script type="text/javascript">


        var paras = {};

        QC.api("get_user_info", paras)
            .success(function(s){//成功回调
                addQQ(s.data.nickname,s.data.gender,s.data.figureurl_qq,s.data.figureurl_1);
                //     alert("获取用户信息成功！当前用户昵称为："+s.data.nickname);
            })
            .error(function(f){//失败回调
                layer.msg('获取用户信息失败');
            })
            .complete(function(c){//完成请求回调
                layer.msg('获取用户信息完成');
            });

        function addQQ(nickname,gender,figureurl1,figureurl2) {
            $.ajax({
                url:"/user/addQQ",
                type:"POST",
                data:{nickname:nickname,gender:gender,figureurl1:figureurl1,figureurl2:figureurl2},
                success:function(result){
                    loginUser(result.userAccout,result.userPwd)
                },
                error:function(){
                    layer.msg('系统繁忙');
                }
            })

        }

        function loginUser(userAccout,userPwd){

            $.ajax({
                url:"/login/userLogin",
                type:"POST",
                data:{userAccout:userAccout,userPwd:userPwd},
                success:function(result){

                    if(result){

                        var prevLink = document.referrer;
                        if($.trim(prevLink)==''){
                            location.href = '/login/login?login=home';
                        }else{
                            if(prevLink.indexOf('removeSession')!=-1){    //来自其它站点
                                location.href = '/login/login?login=home';
                            }
                            if(prevLink.indexOf('login=login')!=-1){      //来自注册页面
                                location.href = '/login/login?login=home';
                            }
                            location.href = prevLink;
                        }
                    }else{

                        $("#msg").html("密码或账号有误");
                        $("#msg").css('color','red');
                        $("#msg").css('size','7px');
                    }
                },
                error:function(){
                    ErroAlert('失败了');
                }
            });

        }





        $(function(){
        $(".screenbg ul li").each(function(){
            $(this).css("opacity","0");
        });
        $(".screenbg ul li:first").css("opacity","1");
        var index = 0;
        var t;
        var li = $(".screenbg ul li");
        var number = li.size();
        function change(index){
            li.css("visibility","visible");
            li.eq(index).siblings().animate({opacity:0},3000);
            li.eq(index).animate({opacity:1},3000);
        }
        function show(){
            index = index + 1;
            if(index<=number-1){
                change(index);
            }else{
                index = 0;
                change(index);
            }
        }
        t = setInterval(show,3000);
        //根据窗口宽度生成图片宽度
        var width = $(window).width();
        $(".screenbg ul img").css("width",width+"px");
    });



    $(function(){
        getDate();


        var str = document.cookie.split(";");

        //获取key为user_pwd的值
        $.each(str, function (index, obj) {
            // console.log(obj)
            var st = obj.split("=");
            //console.log(st[0])
            if (st[0].trim() == "login") {
                // console.log(st[1])
                var arr =  st[1].split("-");
                // console.log(arr);

                $("[name='userAccout']").val(arr[0]);
                $("[name='userPwd']").val(arr[1]);

                $("[name='check']").prop("checked",true);

            }
        });
    })


    function getDate(){

        $("#span1").html(new Date().toLocaleString());
    }

    function queryUserLogin(){
        $.ajax({
            url:"/login/userLogin",
            type:"POST",
            data:$("#user_form").serialize(),
            async:false,
            success:function(result){
                if(result){

                    var prevLink = document.referrer;
                    if($.trim(prevLink)==''){
                        location.href = '/login/login?login=home';
                    }else{
                        if(prevLink.indexOf('removeSession')!=-1){    //来自其它站点
                            location.href = '/login/login?login=home';
                        }
                        if(prevLink.indexOf('login=login')!=-1){      //来自注册页面
                            location.href = '/login/login?login=home';
                        }
                        location.href = prevLink;
                    }
                }else{

                    $("#msg").html("密码或账号有误");
                    $("#msg").css('color','red');
                    $("#msg").css('size','7px');
                }
            },
            error:function(){
                layer.alert("网络不好，请重试");
            }
        })

    }

        function clearAllCookie() {
            var date=new Date();
            date.setTime(date.getTime()-10000);
            var keys=document.cookie.match(/[^ =;]+(?=\=)/g);
            console.log("需要删除的cookie名字："+keys);
            if (keys) {
                for (var i =  keys.length; i--;)
                    document.cookie=keys[i]+"=0; expire="+date.toGMTString()+"; path=/";
            }
        }


</script>

    <script type="text/javascript">
        //从页面收集openapi必要的参数
        var paras = {
            images:"http://y.photo.qq.com/img?s=OnbP8BwOF&l=y.jpg",
            title:"#QQ互联JSSDK测试#我是标题啊标题",
            url:"http://connect.qq.com/",
            comment:"我是评论：转发原因",
            summary:"我是摘要：内容说明"
        };

        //用jssdk调用openapi
        QC.api("add_share", paras)
            .success(function(s){//请自行改写成功回调
                //     alert("分享成功，请到空间内查看！");
            })
            .error(function(f){//请自行改写失败回调
                //   alert("分享失败！");
            })
            .complete(function(c){//请自行改写完成请求回调
                //    alert("分享完成！");
            });
    </script>

    <script type="text/javascript">
        var paras = {content : "#QQ互联JSSDK测试#曾经沧海难为水，除却巫山不是云。"};

        QC.api("add_t", paras)
            .success(function(s){//成功回调
                //       alert("发送微博成功，请到腾讯微博内查看！");
            })
            .error(function(f){//失败回调
                //       alert("发送微博失败！");
            })
            .complete(function(c){//完成请求回调
                //       alert("发送微博完成！");
            });
    </script>
    <script type="text/javascript">
        if(QC.Login.check()){//如果已登录
            QC.Login.getMe(function(openId, accessToken){
              //        alert(["当前登录用户的", "openId为："+openId, "accessToken为："+accessToken].join("\n"));
            });
            //这里可以调用自己的保存接口
            //...
        }
    </script>




</head>

<body>
<input type="hidden" id="status" th:value="${session.user?.status}">
<div id="tab">
    <ul class="tab_menu">
        <!--    <li class="selected">用户登录</li>
         <li>导师登录</li>
          <li>教务登录</li> -->
    </ul>
    <div class="tab_box">
        <!-- 学生登录开始 -->
        <div>

            <span  id="msg">用户登录</span>
            <form  id="user_form" >
                <div id="username">
                    <label>帐&nbsp;&nbsp;&nbsp;号：</label>
                    <input type="text" name="userAccout"/>
                </div>
                <div id="password">
                    <label>密&nbsp;&nbsp;&nbsp;码：</label>
                    <input type="password"  name="userPwd"/>
                </div>

                <div id="remember">
                    <input type="checkbox" value="1" name="check">
                    <label>记住密码&nbsp;&nbsp;&nbsp;&nbsp;<span id="qqLoginBtn"></span></label>
                </div>
                <div id="login">
                    <input type="button" value="登录"  style="width:260px; height:50px; color:red" onclick="queryUserLogin()">
                </div>
            </form>
        </div>
        <!-- 学生登录结束-->

    </div>
</div>
<div class="bottom">
    <span id="span1"></span>
</div>
<div class="screenbg">
    <ul>
        <li><a href="javascript:;"><img src="/js/login/images/0.jpg"></a></li>
        <li><a href="javascript:;"><img src="/js/login/images/1.jpg"></a></li>
        <li><a href="javascript:;"><img src="/js/login/images/2.jpg"></a></li>
    </ul>
</div>
</body>
</html>